#include "mainwindow.h"
#include "top_widget/top_widget.h"
#include "top_widget/top_widget_view_ctrl.h"
#include <QSplitter>

MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
  InitForm();
  InitTitleBar();
  InitMenuBar();
  InitCenterWidget();
  InitConn();

  InitSocket();
  InitRightWgt();
}

MainWindow::~MainWindow() {}

void MainWindow::InitForm() {
  QString style(R"(

#titleBar {
background: #BBBBBB;
border-top-left-radius: 8px;
border-top-right-radius: 8px;
background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 #64707f, stop:1 #4b5868);
}

#menuBar {
border: 2px solid #BBBBBB;
border-top: 0px solid #BBBBBB;
background: #FFFFFF;
background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 #d6d6d6, stop:1 #c6c6c6);
}

#widgetMain {
border: 2px solid #BBBBBB;
border-top: 0px solid #BBBBBB;
background: #FFFFFF;
/* border-bottom-left-radius:8px; border-bottom-right-radius:8px; */

}

)");
  this->setStyleSheet(style);
}

void MainWindow::InitTitleBar() {}

void MainWindow::InitMenuBar() {}

void MainWindow::InitRightWgt() {}

void MainWindow::InitCenterWidget() {
  // 在 Init() 或构造函数中设置
  this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
  QVBoxLayout *mainVbox = new QVBoxLayout;
  mainVbox->setContentsMargins(0,0,0,0);

  projectTreeDock_ = new ProjectTreeDock(this);
  projectTreeDock_->Init();

  QWidget *rigth  = new QWidget;
  QSplitter *split = new QSplitter(this);
  mainVbox->addWidget(split);
  split->addWidget(projectTreeDock_);
  split->addWidget(rigth);
  split->setOrientation(Qt::Horizontal);

  InitRigthPage(rigth);

  this->setCentralWidget(split);
}


void MainWindow::InitRigthPage(QWidget *widget)
{
    QVBoxLayout *vbox =new QVBoxLayout;
    vbox->setContentsMargins(0,0,0,0);
    TopWidget *topWidget  = new TopWidget(this);
    topWidget->Init();
    QTabWidget *meddleWidget  = new QTabWidget;
//    meddleWidget->setFixedSize(960, 720);
    QTabWidget *buttomWidget  = new QTabWidget;
    InitTopWidget(topWidget);
    InitMeddimWidget(meddleWidget);
    InitButtomWidget(buttomWidget);

    vbox->addWidget(topWidget);
    vbox->addWidget(meddleWidget);
    vbox->addWidget(buttomWidget);
    widget->setLayout(vbox);
}

void MainWindow::InitTopWidget(QWidget *widget)
{

}

void MainWindow::InitMeddimWidget(QTabWidget *tabWidget)
{
    QWidget *message = new QWidget;
    QWidget *logWidet = new QWidget;
    tabWidget->addTab(message, "AWB");
    tabWidget->addTab(logWidet, "Curve");
}

void MainWindow::InitButtomWidget(QTabWidget *tabWidget)
{
//    QTabWidget *tabWidget = new QTabWidget;
    QWidget *message = new QWidget;
    QWidget *logWidet = new QWidget;
    tabWidget->addTab(message, "Message");
    tabWidget->addTab(logWidet, "log");
}

void MainWindow::InitConn() {}

void MainWindow::InitSocket() {}

void MainWindow::InitTopic() {}
